测试
# 执行测试任务
请求
POST /openapi/quality/testing/task
1
Body 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
project_key | 项目标识 | string | 是 |
test_name | 测试名称 | string | 是 |
repo_info | 代码库运行时配置,未指定时使用测试配置中的默认值 | []RepoInfo | 否 |
inputs | 运行时变量,未指定的变量使用测试配置中的默认值 | []Input | 否 |
RepoInfo 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
codehost_name | 代码源名称 | string | 是 |
repo_namespace | 代码库所属命名空间(组织/个人) | string | 是 |
repo_name | 代码库名称 | string | 是 |
branch | 分支名称,enable_commit 为 false 时必填 | string | 否 |
pr | Pull Request 编号 | int | 否 |
prs | Pull Request 编号列表 | []int | 否 |
enable_commit | 是否使用指定 Commit | bool | 否 |
commit_id | Commit ID,enable_commit 为 true 时必填 | string | 否 |
repo_info 中的代码库必须已配置在该测试中,不支持覆盖 Perforce 代码库。
Input 参数说明
| 参数名 | 说明 | 类型 | 必填 |
|---|---|---|---|
key | 变量名称,必须已配置在该测试中 | string | 是 |
value | 变量值 | string | 否 |
type | 变量类型 | string | 否 |
is_credential | 是否为敏感变量 | bool | 否 |
file_id | 文件 ID | string | 否 |
file_name | 文件名称 | string | 否 |
file_path | 文件路径 | string | 否 |
Body 参数示例
{
"project_key": "demo",
"test_name": "test-demo",
"repo_info": [
{
"codehost_name": "github",
"repo_namespace": "koderover",
"repo_name": "zadig",
"branch": "main"
}
],
"inputs": [
{
"key": "ENV",
"value": "test"
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
成功返回
| 参数名 | 类型 | 描述 |
|---|---|---|
task_id | int | 测试任务 ID |
{
"task_id": 27
}
1
2
3
2
3
失败返回
{
"code": 500,
"description": "mongo: no documents in result",
"message": "Internal Error: "
}
1
2
3
4
5
2
3
4
5
# 获取测试变量
获取测试的运行时变量定义。敏感变量的 value 不会返回,可通过 has_value 判断是否已配置值。
请求
GET /openapi/quality/testing/:testName?projectKey=<项目标识>
1
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
testName | string | 测试名称 | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
成功返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
project_key | string | 项目标识 |
test_name | string | 测试名称 |
inputs | []TestInput | 运行时变量定义 |
TestInput 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
key | string | 变量名称 |
value | string | 默认值,敏感变量不返回该字段 |
type | string | 变量类型 |
choice_option | []string | 可选值列表 |
required | bool | 是否必填 |
is_credential | bool | 是否为敏感变量 |
has_value | bool | 是否已配置值 |
description | string | 变量描述 |
成功返回示例
{
"project_key": "demo",
"test_name": "test-demo",
"inputs": [
{
"key": "ENV",
"value": "test",
"type": "choice",
"choice_option": [
"test",
"production"
],
"required": true,
"is_credential": false,
"has_value": true,
"description": "运行环境"
},
{
"key": "PASSWORD",
"type": "string",
"required": true,
"is_credential": true,
"has_value": true
}
]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 获取测试任务详情
请求
GET /openapi/quality/testing/:testName/task/:taskID?projectKey=<项目标识>
1
路径参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
testName | string | 测试名称 | 是 |
taskID | int | 测试任务 ID | 是 |
Query 参数说明
| 参数名 | 类型 | 描述 | 必填 |
|---|---|---|---|
projectKey | string | 项目标识 | 是 |
成功返回说明
| 参数名 | 类型 | 描述 |
|---|---|---|
test_name | 测试名称 | string |
task_id | 测试任务 ID | int |
creator | 创建者 | string |
create_time | 创建时间 | int |
start_time | 任务开始执行时间 | int |
end_time | 任务结束执行时间 | int |
status | 当前状态:created:测试任务已创建running:测试任务正在执行passed:测试任务执行通过skipped:测试任务未执行跳过failed:测试任务执行失败timeout:测试任务执行超时cancelled:测试任务已取消waiting:测试任务等待执行queued:测试任务已加入执行队列中 | string |
test_report | 测试报告 | Report |
Report 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
test_total | 总测试用例数量 | int |
failure_total | 失败测试用例数量 | int |
success_total | 成功测试用例数量 | int |
skiped_total | 未执行测试用例数量 | int |
error_total | 错误测试用例数量 | int |
test_cases | 测试用例列表 | []TestCase |
TestCase 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
name | 用例名称 | string |
time | 用时,单位 秒 | int |
failure | 失败信息 | Message |
skipped | 未执行信息 | 空结构体,该值为 null 代表此测试用例已执行,否则返回空结构体 |
error | 错误信息 | Message |
Message 参数说明
| 参数名 | 类型 | 描述 |
|---|---|---|
message | 错误消息摘要 | string |
type | 类型 | string |
text | 错误具体内容 | string |
成功返回示例
{
"test_name": "test-demo",
"task_id": 16,
"creator": "cici",
"create_time": 1689823467,
"start_time": 1689823470,
"end_time": 1689823491,
"status": "passed",
"test_report": {
"test_total": 24,
"failure_total": 0,
"success_total": 24,
"skiped_total": 0,
"error_total": 0,
"time": 13.872,
"test_type": "",
"name": "",
"test_cases": [
{
"name": "e2e Test Suites Scenario 1 - 现有项目的回归测试 被测试环境中存在一个叫做voting的项目 可以查看环境",
"time": 0.155922912,
"failure": null,
"skipped": null,
"error": null
},
{
"name": "e2e Test Suites Scenario 1 - 现有项目的回归测试 被测试环境中存在一个叫做voting的项目 可以查看Voting项目信息",
"time": 0.136967508,
"failure": null,
"skipped": null,
"error": null
},
{
"name": "e2e Test Suites Scenario 2 - onboarding的核心流程 经过系统的onboarding流程,自动生成了环境和一些工作流 成功的自动创建了环境和工作流,工作流可以被触发",
"time": 7.83081332,
"failure": null,
"skipped": null,
"error": null
}
]
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
失败返回
{
"code": 500,
"description": "failed to get pipeline task from db, taskID:1, pipelineName:tt-job, err: mongo: no documents in result",
"message": "Internal Error: "
}
1
2
3
4
5
2
3
4
5


